package com.design.create.prototype;

import java.util.ArrayList;

/**
 * 深拷贝实现原型模式
 */
public class DeepClonePrototype extends Prototype{

    @Override
    public Prototype clone() {
        Prototype prototype = null;
        try {
            prototype = (Prototype) super.clone();
        } catch (CloneNotSupportedException e) {
            throw new RuntimeException(e);
        }
        prototype.list = (ArrayList<String>) this.list.clone();
        return prototype;
    }

    @Override
    public void show() {
        System.out.println("深拷贝实现");
    }
}
